home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / DTS Japan-Sample Code / AppleEvent•MacApp2.0•QuickDraw / UDraw.h < prev    next >
Encoding:
Text File  |  1992-02-05  |  10.9 KB  |  304 lines  |  [TEXT/MPS ]

  1. //---------------------------------------------------------------------
  2. //     Copyright © 1991 Apple Computer, Japan Inc. All rights reserved.
  3. //
  4. //        '91 Dec.11  Programed by Taro Tanaka
  5. //
  6. //        Developer Technical Supprt, Service and Support
  7. //        
  8. //---------------------------------------------------------------------
  9.  
  10. #include <UMacApp.h>
  11. #include <UPrinting.h>
  12. #include <UDialog.h>
  13. #include <UGridView.h>
  14. #include <ToolUtils.h>
  15. #include <Resources.h>
  16.  
  17. #include <Aliases.h>
  18. #include <AppleEvents.h>
  19. #include <AEObjects.h>
  20. #include <AEPackObject.h>
  21. #include <Processes.h>
  22. #include <StandardFile.h>
  23. #include <Packages.h>
  24. #include <Sound.h>
  25.  
  26. class TDraw;            // forward declarations
  27. class TDrawView;
  28. class TPaletteView;
  29. class TShapeGridView;
  30. class TDrawingRect;
  31. class TDrawingOval;
  32. class TDrawingLine;
  33.  
  34. typedef pascal void (*DoToADrawProc)(TDraw *aDraw, void *link);
  35.  
  36. // ==========================================================================================
  37. class TDrawApplication: public TApplication {
  38. public:
  39.     virtual pascal void IDrawApplication();
  40.     virtual pascal TDocument* DoMakeDocument(CmdNumber itsCmdNumber);
  41.     virtual pascal TCommand* DoMenuCommand(CmdNumber aCmdNumber);
  42.     virtual pascal void DoSetupMenus();
  43.     virtual pascal TCommand* HandleAlienEvent(EventInfo *theEventInfo);
  44.     virtual pascal void HandleFinderRequest();
  45. };
  46.  
  47. // ==========================================================================================
  48. class TDrawDocument: public TDocument {
  49. private:
  50.     TPaletteView    *fPaletteView;
  51.     TList            *fDrawList;
  52.     short            fColorCmdNumber;
  53.     short            fLineCmdNumber;
  54. public:
  55.     TDrawView        *fDrawView;
  56.     virtual pascal void IDrawDocument();
  57.     virtual pascal void AddDrawFirst(TDraw *aDraw);
  58.     virtual pascal void AddDrawLast(TDraw *aDraw);
  59.     virtual pascal CmdNumber GetColorCmd();
  60.     virtual pascal void SetColorCmd(CmdNumber aCmdNumber);
  61.     virtual pascal CmdNumber GetLineCmd();
  62.     virtual pascal void SetLineCmd(CmdNumber aCmdNumber);
  63.     virtual pascal void DeleteDraw(TDraw *aDraw);
  64.     virtual pascal void DoMakeViews(Boolean forPrinting);
  65.     virtual pascal void DoSetupMenus();
  66.     virtual pascal TCommand *  DoMenuCommand(CmdNumber aCmdNumber);
  67.     virtual pascal TDraw  *FirstDraw();
  68.     virtual pascal void ForEachDrawDo(DoToADrawProc DoToADraw, void *DoToDraw_StaticLink);
  69.     virtual pascal void Free();            //override
  70.     virtual pascal void FreeData();        //overrride
  71.     virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
  72.     virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
  73.     virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
  74. #if qInspector
  75.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  76.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  77. #endif
  78. };
  79.         
  80.         
  81. // ==========================================================================================
  82. class TDrawView: public TView {
  83. private:
  84.     TDrawDocument    *fDrawDocument;
  85.     OSType            fShapeType;
  86. public:
  87.     virtual pascal void     IRes(TDocument *itsDocument,
  88.                                          TView *itsSuperView, Ptr *itsParams);
  89.     virtual pascal TCommand *DoMouseCommand(Point *theMouse,
  90.                                         EventInfo *info, Point *hysteresis);
  91.     virtual pascal Boolean    DoSetCursor(Point localPoint, RgnHandle cursorRgn);
  92.     virtual pascal void     Draw(Rect *area);
  93.     virtual pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint, Boolean turnItOn, Boolean mouseDidMove);
  94. };
  95.  
  96.         
  97. // ==========================================================================================
  98. class TPaletteView: public TView {
  99. private:
  100.     TDrawDocument    *fDrawDocument;
  101.     
  102. public:
  103.     virtual pascal void IRes(TDocument *itsDocument,
  104.                          TView *itsSuperView, Ptr *itsParams);
  105.     virtual pascal void ChangeSelection(CmdNumber newColorNumber);
  106.     virtual pascal TCommand *DoMouseCommand(Point *theMouse,
  107.                         EventInfo *info, Point * hysteresis);
  108.     virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
  109.     virtual pascal void Draw(Rect *area);
  110. #if qInspector
  111.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  112.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  113. #endif
  114. };
  115.  
  116. // ==========================================================================================
  117. class TLineView: public TView {
  118. private:
  119.     TDrawDocument    *fDrawDocument;
  120. public:
  121.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  122.     virtual pascal void ChangeSelection(CmdNumber newColorNumber);
  123.     virtual pascal TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point * hysteresis);
  124.     virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
  125.     virtual pascal void Draw(Rect *area);
  126. };
  127.  
  128. // ==========================================================================================
  129. class TDraw: public TObject {
  130. public:
  131.     OSType    fShapeType;
  132.     Rect        fFrame;
  133.     RGBColor    fColor;
  134.     Pattern    fPattern;
  135.     short        fLineSize;
  136.     virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
  137.     virtual pascal void DrawDraw();        
  138.     virtual pascal long ReturnBytes();
  139.     virtual pascal void ReadDraw(short aRefNum);
  140.     virtual pascal void WriteDraw(short aRefNum);
  141.     virtual pascal Rect ReturnFrame();
  142. #if qInspector
  143.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  144.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  145. #endif
  146. };
  147.  
  148. // ==========================================================================================
  149. class TDrawingRect: public TDraw {
  150.     virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
  151.     virtual pascal void DrawDraw();
  152. };
  153.  
  154. // ==========================================================================================
  155. class TDrawingOval: public TDraw {
  156.     virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
  157.     virtual pascal void DrawDraw();        
  158. };
  159.  
  160. // ==========================================================================================
  161. class TDrawingLine: public TDraw {
  162. private:
  163.     Point        fStartPoint;
  164.     Point        fEndPoint;
  165. public:
  166.     virtual pascal void IDraw(const Rect *size, RGBColor *itsColor, ConstPatternParam *itsPattern, short itsLineSize);
  167.     virtual pascal void DrawDraw();        
  168.     virtual pascal long ReturnBytes();
  169.     virtual pascal void ReadDraw(short aRefNum);
  170.     virtual pascal void WriteDraw(short aRefNum);
  171.     virtual pascal void IStartEnd(Point startPoint, Point endPoint);
  172. };
  173.  
  174. // ==========================================================================================
  175. class TDrawingRRect: public TDraw {
  176. private:
  177.     Point        fOval;
  178. public:
  179.     virtual pascal void IDraw(const Rect *size, RGBColor *itsColor,ConstPatternParam *itsPattern, short itsLineSize);
  180.     virtual pascal void DrawDraw();    
  181.     virtual pascal long ReturnBytes();
  182.     virtual pascal void ReadDraw(short aRefNum);
  183.     virtual pascal void WriteDraw(short aRefNum);
  184.     virtual pascal void ISetOval(Point ovalSize);
  185. };
  186.  
  187. // ==========================================================================================
  188. class TDrawingPICT: public TDraw {
  189. private:
  190.     PicHandle    fPicHandle;
  191. public:
  192.     virtual pascal void IDraw(const Rect *size, RGBColor *itsColor,ConstPatternParam *itsPattern, short itsLineSize);
  193.     virtual pascal void DrawDraw();    
  194.     virtual pascal long ReturnBytes();
  195.     virtual pascal void ReadDraw(short aRefNum);
  196.     virtual pascal void WriteDraw(short aRefNum);
  197.     virtual pascal void ISetPICT(PicHandle itsPICTHandle);
  198. };
  199.  
  200. // ==========================================================================================
  201. class TSketcher: public TCommand {
  202. private:
  203.     TDraw                *fDraw;
  204.     TDrawView        *fDrawView;        
  205.     TDrawDocument    *fDrawDocument;
  206.     OSType            fShapeType;
  207.     
  208. public:
  209.     virtual pascal void ISketcher(TDrawView *itsView, TDrawDocument*itsDocument, OSType fShapeType);
  210.     virtual pascal TCommand *TrackMouse(TrackPhase aTrackPhase,
  211.                             VPoint *anchorPoint, 
  212.                             VPoint *previousPoint, 
  213.                             VPoint *nextPoint,
  214.                             Boolean mouseDidMove);
  215.     virtual pascal void DoIt();
  216.     virtual pascal void RedoIt();
  217.     virtual pascal void UndoIt();
  218.     virtual pascal void Free();
  219. #if qInspector
  220.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  221.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  222. #endif
  223. };
  224.         
  225. // ==========================================================================================
  226. class TDeleteCmd: public TCommand {
  227. private:
  228.     TDraw            *fDeletedDraw;
  229.     TDrawView        *fDrawView;
  230.     TDrawDocument    *fDrawDocument;
  231.     
  232. public:
  233.     virtual pascal void IDeleteCmd(TDrawView *itsView, 
  234.       TDrawDocument *itsDocument);
  235.     virtual pascal void DoIt();
  236.     virtual pascal void RedoIt();
  237.     virtual pascal void UndoIt();
  238.     virtual pascal void Free();
  239. #if qInspector
  240.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  241.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  242. #endif
  243. };
  244.         
  245. // ==========================================================================================
  246. class TShapeGridView: public TGridView {
  247. public:
  248.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  249.     virtual pascal void DrawCell(GridCell aGridCell, Rect *aQDRect);
  250.     virtual pascal OSType GetShapeType();
  251. };
  252.  
  253. // ==========================================================================================
  254. class TPatternView: public TGridView {
  255. private:
  256.     virtual pascal void DrawCell(GridCell aGridCell, Rect *aQDRect);
  257. public:
  258.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  259.     virtual pascal void GetPattern(Pattern itsPattern);
  260. };
  261.  
  262. // ==========================================================================================
  263. class TSetSelfCmd: public TNoChangesCommand {
  264.     virtual pascal void DoIt();
  265. };
  266.  
  267. // ==========================================================================================
  268. class TSetTargetAddress: public TNoChangesCommand {
  269.     virtual pascal void DoIt();
  270. };
  271.  
  272. // ==========================================================================================
  273. class TLaunchApplication: public TNoChangesCommand {
  274.     virtual pascal void DoIt();
  275. };
  276.  
  277. // ==========================================================================================
  278. class TAEOldDocCommand: public TOldDocCommand {
  279. public:
  280.     virtual pascal void IAEOldDocCommand(CmdNumber itsCmdNumber);
  281.     virtual pascal void DoIt();
  282. };
  283.  
  284. // ==========================================================================================
  285. class TAENewDocCommand: public TNewDocCommand {
  286. public:
  287.     virtual pascal void IAENewDocCommand(CmdNumber itsCmdNumber);
  288.     virtual pascal void DoIt();
  289. };
  290.  
  291. // ==========================================================================================
  292. class TAECloseWindowCommand: public TCloseWindowCommand {
  293. public:
  294.     virtual pascal void IAECloseWindowCommand(CmdNumber itsCmdNumber);
  295.     virtual pascal void DoIt();
  296. };
  297.  
  298. // ==========================================================================================
  299. class TAEAboutAppCommand: public TAboutAppCommand {
  300. public:
  301.     virtual pascal void DoIt();
  302. };
  303.  
  304.